from tools.consts import FILE


def print_tip(username, current_path):
    print("{}:{}> ".format(username, current_path), end="")


def process_command(command):
    command_list = command.split(" ")
    if len(command_list) >= 2:
        return command_list[0], command_list[1:]
    else:
        return command_list[0], [None]


def output_dir(dir_list):
    if len(dir_list) > 0:
        print(
            "{0:<15}\t{1:<26}\t{2:<4}\t{3:<4}\t{4:<4}\t{5:<4}".format("own_permission", "create_time", "name", "size", "type",
                                                               "owner"))
    for item in dir_list:
        print(
            "{0:<15}\t{1}\t{2:<4}\t{3:<4}\t{4:<4}\t{5:<4}".format(item.inode.file_own_permission,
                                                                  item.inode.file_create_time,
                                                                  item.filename if item.inode.file_type == FILE else item.dirname,
                                                                  item.inode.file_size, item.inode.file_type,
                                                                  item.inode.file_own))
